package net.jumpengine.bean;

import java.util.List;

import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image;
import net.jumpengine.Manager;
import net.jumpengine.util.UComm;

public class IconsBase extends ChangeBase {
	private List<Image> list;
	private int num=0;
	private Enum<?> newState;

	public IconsBase(int interval,List<Image> list,Enum<?> newState) {
		super(0, 0, interval);
		this.list=list;
		this.newState=newState;
	}

	@Override
	protected void invoke() {
		num++;
		if(num>=UComm.size(list)) {
			Manager.setState(newState);
		}
		Manager.getLog().debug("IconsBase[invoke]index:%d", num);
	}

	@Override
	public void draw(GraphicsContext g) {
		if(num>=list.size())return;
		Image img=list.get(num);
		g.drawImage(img, (Manager.getWidth()-img.getWidth())/2, (Manager.getHeight()-img.getHeight())/2);
	}

	@Override
	public boolean isAble() {
		return true;
	}

}
